using System;
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
using BW.WMS.OperationKanban.WCL.Dto.Input;
using BW.WMS.OperationKanban.WCL.Dto.Output;
using BW.WMS.CodeEnum;
using System.Collections.Generic;

namespace BW.WMS.OperationKanban.WCL
{
    /// <summary>
    /// 货品管理服务接口
    /// </summary>
    public interface IGoodsManagementAppService : IApplicationService
    {
        /// <summary>
        /// 获取货品列表
        /// </summary>
        Task<List<GoodsOutput>> GetGoodsListAsync(GoodsQueryInput input);

        /// <summary>
        /// 获取库存汇总信息
        /// </summary>
        /// <returns>库存汇总</returns>
        Task<InventorySummaryOutput> GetInventorySummaryAsync();

        /// <summary>
        /// 导出货品数据
        /// </summary>
        /// <param name="input">查询条件</param>
        /// <returns>导出文件</returns>
        Task<byte[]> ExportGoodsDataAsync(GoodsQueryInput input);

        /// <summary>
        /// 获取货品类型列表
        /// </summary>
        /// <returns>货品类0000列表</returns>
        Task<ListResultDto<ItemTypeDto>> GetItemTypesAsync();

        /// <summary>
        /// 获取单位列表
        /// </summary>
        /// <returns>单位列表</returns>
        Task<ApiPaging<UnitDto>> GetUnitsAsync();

        /// <summary>
        /// 获取仓库列表
        /// </summary>
        /// <returns>仓库列表</returns>
        Task<ListResultDto<WarehouseDto>> GetWarehousesAsync();

        /// <summary>
        /// 获取库位列表
        /// </summary>
        /// <param name="warehouseId">仓库ID</param>
        /// <returns>库位列表</returns>
        Task<ListResultDto<LocationDto>> GetLocationsAsync(string warehouseId = null);

        /// <summary>
        /// 获取库位下拉框数据
        /// </summary>
        /// <param name="warehouseId">仓库ID</param>
        /// <returns>库位下拉框数据</returns>
        Task<List<LocationSelectDto>> GetLocationSelectListAsync(string warehouseId = null);

        /// <summary>
        /// 刷新数据
        /// </summary>
        /// <returns>刷新结果</returns>
        Task<bool> RefreshDataAsync();

        /// <summary>
        /// 测试数据库连接
        /// </summary>
        /// <returns>测试结果</returns>
        Task<string> TestDatabaseConnectionAsync();

        /// <summary>
        /// 添加货品
        /// </summary>
        /// <param name="input">货品信息</param>
        /// <returns>添加结果</returns>
        Task<GoodsOutput> AddGoodsAsync(AddGoodsInput input);

        /// <summary>
        /// 修改货品
        /// </summary>
        /// <param name="input">货品信息</param>
        /// <returns>修改结果</returns>
        Task<GoodsOutput> UpdateGoodsAsync(UpdateGoodsInput input);

        /// <summary>
        /// 删除货品
        /// </summary>
        /// <param name="id">货品ID</param>
        /// <returns>删除结果</returns>
        Task<bool> DeleteGoodsAsync(Guid id);

        /// <summary>
        /// 根据ID获取货品详情
        /// </summary>
        /// <param name="id">货品ID</param>
        /// <returns>货品详情</returns>
        Task<GoodsOutput> GetGoodsByIdAsync(Guid id);
        
        /// <summary>
        /// 获取货品库存详情
        /// </summary>
        /// <param name="goodsId">货品ID</param>
        /// <returns>货品库存详情</returns>
        Task<GoodsInventoryDetailOutput> GetGoodsInventoryDetailAsync(Guid goodsId);
        
        /// <summary>
        /// 获取货品库存详情（按货品编号）
        /// </summary>
        /// <param name="itemId">货品编号</param>
        /// <returns>货品库存详情</returns>
        Task<GoodsInventoryDetailOutput> GetGoodsInventoryDetailByItemIdAsync(string itemId);
        
        /// <summary>
        /// 导出货品库存明细
        /// </summary>
        /// <param name="goodsId">货品ID</param>
        /// <returns>导出文件字节数组</returns>
        Task<byte[]> ExportGoodsInventoryDetailAsync(Guid goodsId);
    }

    /// <summary>
    /// 货品类型DTO
    /// </summary>
    public class ItemTypeDto
    {
        public Guid Id { get; set; }
        public string ItemTypeId { get; set; }
        public string ItemTypeName { get; set; }
        public float Status { get; set; }
    }

    /// <summary>
    /// 单位DTO
    /// </summary>
    public class UnitDto
    {
        public string Id { get; set; }
        public string UnitId { get; set; }
        public string UnitName { get; set; }
        public float Status { get; set; }
    }

    /// <summary>
    /// 仓库DTO
    /// </summary>
    public class WarehouseDto
    {
        public Guid Id { get; set; }
        public string WarehouseId { get; set; }
        public string WarehouseName { get; set; }
        public float Status { get; set; }
    }

    /// <summary>
    /// 库位DTO
    /// </summary>
    public class LocationDto
    {
        public Guid Id { get; set; }
        public string LocationId { get; set; }
        public string LocationName { get; set; }
        public string WarehouseId { get; set; }
        public float Status { get; set; }
    }

    /// <summary>
    /// 库位选择DTO
    /// </summary>
    public class LocationSelectDto
    {
        /// <summary>
        /// 库位ID
        /// </summary>
        public string Value { get; set; }

        /// <summary>
        /// 库位名称
        /// </summary>
        public string Label { get; set; }

        /// <summary>
        /// 仓库ID
        /// </summary>
        public string WarehouseId { get; set; }
    }
} 